import { app } from 'electron'
import { showAboutDialog } from '../actions/help'
import * as actions from '../actions/marktext'
import { COMMANDS } from '../../commands'

export default function (keybindings, language) {
  return {
    label: 'MarkText',
    submenu: [{
      label: language.getString('aboutMarkText'),
      click (menuItem, focusedWindow) {
        showAboutDialog(focusedWindow)
      }
    }, {
      label: language.getString('checkForUpdates'),
      click (menuItem, focusedWindow) {
        actions.checkUpdates(focusedWindow)
      }
    }, {
      label: language.getString('preferences'),
      accelerator: keybindings.getAccelerator(COMMANDS.FILE_PREFERENCES),
      click () {
        actions.userSetting()
      }
    }, {
      type: 'separator'
    }, {
      label: language.getString('services'),
      role: 'services',
      submenu: []
    }, {
      type: 'separator'
    }, {
      label: language.getString('hideMarkText'),
      accelerator: keybindings.getAccelerator(COMMANDS.MT_HIDE),
      click () {
        actions.osxHide()
      }
    }, {
      label: language.getString('hideOthers'),
      accelerator: keybindings.getAccelerator(COMMANDS.MT_HIDE_OTHERS),
      click () {
        actions.osxHideAll()
      }
    }, {
      label: language.getString('showAll'),
      click () {
        actions.osxShowAll()
      }
    }, {
      type: 'separator'
    }, {
      label: language.getString('quitMarkText'),
      accelerator: keybindings.getAccelerator(COMMANDS.FILE_QUIT),
      click: app.quit
    }]
  }
}
